package com.weblog.search.client.factory;

import com.weblog.search.client.CategoryClient;
import com.weblog.search.client.impl.CategoryClientImpl;
import entity.Result;
import entity.StatusCode;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * @author MaoLin Wang
 * @date 2019/10/2013:42
 */
@Component
public class CategoryFallBackFactory  implements FallbackFactory<CategoryClient> {
    @Override
    public CategoryClient create(Throwable throwable) {
        System.out.println("搜索微服务调用分类客户端出错："+throwable.getMessage()==null?"":throwable.getMessage());
        throwable.printStackTrace();
        return new CategoryClientImpl() {

            @Override
            public Result findCnameById(String id) {
                return new Result(false, StatusCode.ERROR,"分类客户端findCnameById错误");
            }

            @Override
            public Result getLevelById(String cid) {
                return new Result(false, StatusCode.ERROR,"分类客户端getLevelById错误");
            }
        };
    }
}
